package org.game.msgBuilder;

import org.game.db.bean.ElementCollection;
import org.game.protobuf.s2c.S2CElementCollectMsg;

import java.util.List;

/**
 * 元素收集（图鉴）
 * Created by fxf on 2018-3-1.
 */
public class ElementCollectMsgBuilder {

    public static S2CElementCollectMsg.GetAllElement buildGetAllElementMsg(ElementCollection elementCollection) {
        S2CElementCollectMsg.GetAllElement.Builder builder = S2CElementCollectMsg.GetAllElement.newBuilder();
        if (elementCollection != null){
            elementCollection.getElementMap().forEach((k, v) -> builder.addElment(buildElementsMsg((int)k,(List<Integer>)v)));
        }
        return builder.build();
    }

    public static S2CElementCollectMsg.AddNewElement buildAddNewElementMsg(int type,int cid){
        S2CElementCollectMsg.AddNewElement.Builder builder = S2CElementCollectMsg.AddNewElement.newBuilder();
        builder.setElment(S2CElementCollectMsg.Element.newBuilder().setType(type).setCid(cid)).build();
        return builder.build();
    }

    public static S2CElementCollectMsg.Elements buildElementsMsg(int type,List<Integer> cidList){
        S2CElementCollectMsg.Elements.Builder builder = S2CElementCollectMsg.Elements.newBuilder();
        builder.setType(type)
                .addAllCids(cidList);
        return builder.build();
    }

}
